"""
新建客户页面
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select

from page.base_page import BasePage
class AddClientPage(BasePage):
    #定位器
    #客户名称
    kh_tjkh_khmc_locator = (By.ID, "name")
    #年营业额
    kh_tjkh_nyye_locator = (By.ID, "annual_revenue")
    #姓名
    kh_tjkh_xm_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr:nth-child(8) > td:nth-child(2) > input")
    #手机
    kh_tjkh_sj_locator = (By.CSS_SELECTOR, "#form1 > table > tbody > tr:nth-child(10) > td:nth-child(4) > input")
    #保存
    kh_tjkh_bc_locator = (By.XPATH, '//*[@id="form1"]/table/tfoot/tr/td/input[1]')


    #输入客户名称
    def input_khmc(self,khmc):
        self.driver.find_element(*self.kh_tjkh_khmc_locator).send_keys(khmc)

    #选择年营业额
    def choose_nyye(self,index):
        source = self.driver.find_element(*self.kh_tjkh_nyye_locator)
        Select(source).select_by_index(index)

    #输入姓名
    def input_xm(self,xm):
        self.driver.find_element(*self.kh_tjkh_xm_locator).send_keys(xm)

    #输入手机
    def input_sj(self,sj):
        self.driver.find_element(*self.kh_tjkh_sj_locator).send_keys(sj)

    #点击保存
    def click_bc(self):
        self.driver.find_element(*self.kh_tjkh_bc_locator).click()
